package com.zsrt.java.day20161226.zsh.demo03;
import java.util.Scanner;
public class Demo062Calculator {
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.println("请输入第一个数字：");
		int first=input.nextInt();
		System.out.println("请在计算符号（+、-、*、/、%）中选择一个输入：");
		String sign=input.next();
		System.out.println("请输入第二个数字：");
		int second=input.nextInt();
		input.close();
		
		calculatorIf(sign,first,second);
	}
			
	public static void calculatorIf(String sign,int first,int second){
		if(sign.equals("+")){
			System.out.println(first+" + "+second+" = "+(first+second));	
		}else if(sign.equals("-")){
			System.out.println(first+" - "+second+" = "+(first-second));
		}else if(sign.equals("*")){
			System.out.println(first+" * "+second+" = "+(first*second));
		}else if(sign.equals("/")){
			if(second==0){
				System.out.println("注意：除数不能为 0 ！！");
			}
			System.out.println(first+" / "+second+" = "+(first/second));
		}else if(sign.equals("%")){
			if(second==0){
				System.out.println("注意：除数不能为 0 ！！");
			}
			System.out.println(first+" % "+second+" = "+(first%second));
		}	
	}
}
